<?php
/**********************
**db_access.inc
**Date Created: 4/13/2009
**Copyright 2009 Tomorrow Tech Industries
**Contact: RPITomorrowTech@gmail.com
**********************/

require_once('shared/errors.inc');
class DBConnection
{
	static function getReadConnection(&$connection)
	{
		$rc = TT_OK;
		//Connection related
		$dbhost = "127.0.0.1";
		$dbuser = "root";
		//THIS IS NOT THE READ PASSWORD AND SHOULD BE CHANGED FOR SECURITY REASONS
		$dbpassword="intellimation";
		$connection=mysql_connect($dbhost, $dbuser, $dbpassword)
			or $rc = TT_ACCESS;
		if( TT_FAILED($rc) )
		{
			echo "read: connect failed<BR>";
			return $rc;
		}

		$db=mysql_select_db("SoftwareIntellistrip", $connection)
			or $rc = TT_GENERAL;
		if( TT_FAILED($rc) )
		{
			echo "read: select failed<BR>";
			return $rc;
		}

		return $rc;
	}

	static function getWriteConnection(&$connection)
	{
		$rc = TT_OK;
		//Connection related
		$dbhost = "127.0.0.1";
		$dbuser = "root";
		//THIS IS NOT THE READ PASSWORD AND SHOULD BE CHANGED FOR SECURITY REASONS
		$dbpassword="intellimation";
		$connection=mysql_connect($dbhost, $dbuser, $dbpassword)
			or $rc = TT_ACCESS;
		if( TT_FAILED($rc) )
		{
			echo "write: connect failed<BR>";
			return $rc;
		}

		$db=mysql_select_db("SoftwareIntellistrip", $connection)
			or $rc = TT_GENERAL;
		if( TT_FAILED($rc) )
		{
			echo "write: select failed<BR>";
			return $rc;
		}

		return $rc;
	}
}
?>
